﻿#region Using

using System;

using Common.Base;

using GameCommon.Base;
using GameCommon.FontHelper;
using GameCommon.ServiceInterfaces;

#endregion

namespace GameCommon.Services
{
    internal class FontService : IFontService
    {
        public Size GetSize(string value, Font font)
        {
            var size = new Size();

            foreach (var c in value)
            {
                FontChar fc;
                if (font.Chars.TryGetValue(c, out fc))
                {
                    size.Width += fc.XAdvance;
                    size.Height = Math.Max(size.Height, fc.Height + fc.YOffset);
                }
            }

            return size;
        }
    }
}